<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="exporter-version" content="Evernote Mac 9.4.6 (461470)"/><meta name="author" content="704206198@qq.com"/><meta name="created" content="2017-10-17 03:24:41 +0000"/><meta name="source" content="desktop.mac"/><meta name="updated" content="2021-07-30 02:30:02 +0000"/><title>DAY07：ES5/String</title></head><body><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">第一节：精讲</span></span></span></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">1.严格模式的概念和作用</span></span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div style="text-align: center;"><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;"><img src="DAY07%EF%BC%9AES5_String.resources/8573D21D-EB64-4A5C-B5BC-76944AA74447.png" height="585" width="970"/><br/></span></span></span></div></div><div style="text-align: center;"><div><br/></div></div><div style="text-align: center;"><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;"><img src="DAY07%EF%BC%9AES5_String.resources/21192E64-A71E-41A5-A828-999BDCB370B0.png" height="437" width="778"/><br/></span></span></span></div></div><div style="text-align: center;"><div><br/></div></div><div style="text-align: center;"><div><br/></div></div><div style="text-align: center;"><div><br/></div></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    除了正常运行模式，ECMAscript5添加了第二种运行模式：“严格模式”（strict mode）。顾名思义，这种模式是的Javascript在更严格的条件下运行。</span></span></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">严格模式的作用：</span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    1.消除了JS语法的一些不合理、不严谨之处，减少一些怪异行为；</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    2.消除代码运行的一些不安全之处，保证代码运行的安全；</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    3.提高编译器效率，增加运行速度；</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    4.为未来新版本的JS做好铺垫</span></span></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    严格模式体现了JS更合理，更安全，更严谨的发展方向，包括IE10在内的主流浏览器都已经支持它了</span></span></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">注意：同样的代码，在“严格模式”中，可能会有不一样的运行结果，一些在“正常模式”下可以正常运行的语句，在“严格模式”下将不能运行</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">，掌握这些内容，有助于更细致深入的理解JS，让你编程一个更好的程序员。</span></div><div><br/></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">2.严格模式的调用</span></span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">如何进入严格模式？</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    进入严格模式的标志，书写这一行语句 </span><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 0, 0); font-family: &quot;Courier New&quot;;">"use strict"</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    老的浏览器会把他当成一串普通的字符串，加以忽略</span></span></span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    “严格模式”有两种调用方式，适用于不同的场合；</span></span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">针对整个脚本文件</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">：将 </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;; font-weight: bold;">"use strict"</span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">放在脚本文件的第一行，则整个脚本文件都将以“严格模式”运行，</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">        如果这行语句不在第一行，则无效，整个脚本以“正常模式”运行。</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">      </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(255, 0, 0); font-family: &quot;Courier New&quot;;"> 如果不同模式的代码文件合并成一个文件，这一点需要特别注意。</span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">针对单个函数</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">：将 </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;; font-weight: bold;">"use strict"</span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">放在函数的第一行，则整个函数以“严格模式”运行。</span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;; font-weight: bold;">脚本文件的变通写法</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">：因为第一种调用方式不利于文件合并，所以更好的做法是，借用第二种方法，将整个脚本文件放在一个立即执行的</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">匿名函数</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">中</span></div><div><br/></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">    <span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">匿名函数：不需要调用，直接执行，可以自调用</span></span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">    (function(){</span></span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">        console.log(1);</span></span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">    })()</span></span></font></div><div><br/></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">3.进入严格模式之后的行为变更</span></span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    进入严格模式之后，需要进行哪些行为变更：</span></span></span></span></span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    1.全局变量声明时，必须加关键字(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">var)</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    正常模式：a = 10;</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    console.log(a)    //10</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    严格模式：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">a = 10;</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    console.log(a)    //a is not defined</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;"> </span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    2.this无法指向全局对象</span></span></span></span></span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    正常模式：function fn(){ console.log(this) }</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    //window</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    严格模式：function fn(){ console.log(this) }</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        //</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">undefined</span></font></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    3.函数内不允许出现重名参数</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        正常模式：function fn( a,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">b,b</span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">){ console.log(a,b) }</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    fn(1,2,3)</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    //1,3</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    严格模式：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">function fn( a,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">b,b</span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">){ }</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);"> </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);"> </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">//报错：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">Duplicate parameter name not allowed in this context</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    在此上下文中不允许出现重复的参数名</span></font></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    4.arguments对象</span></span></span></span></span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    4.1 arguments对象不允许被动态改变</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    正常模式：function fn(a){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">a=20;</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">console.log(a);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    //20</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">console.log(arguments[0]);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">     //<span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">2</span></span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">0</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">}</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    fn(10);</span></font></div><div><br/></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    严格模式：function fn(a){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">a=20;</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">console.log(a);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    //20</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">console.log(arguments[0]);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;"> //<span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">1</span></span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">0</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">   </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">}</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    fn(10);</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    4.2 arguments对象不允许被自调用（递归）</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    正常模式：function fn(a){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    if( a == 1 ){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    return 1;</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">}</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    return arguments.callee(a-1) + a;</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">}</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    fn(3);</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    //6</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    严格模式：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">function fn(a){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    if( a == 1 ){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    return 1;</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">}</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    return arguments.callee(a-1) + a;</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">}</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    //报错：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    //报错："caller"，"arguments"，"callee"，不能在严格模式下使用</span></font></div><div><br/></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    5.新增的保留字：implements，interface，let，package，private，protected，public，static，yield</span></span></span></span></span></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">4.ES5新增数组常见方法（indexof／forEach／map／filter）</span></span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    新增的数组常见方法：以下说明中，</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">红色为必选参数</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">，</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(4, 51, 255);">蓝色为可选参数</span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    1.indexOf(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">data</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(4, 51, 255); font-family: &quot;Courier New&quot;;">start</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">);</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        用于返回某个数组或者字符串中规定字符或者字符串的位置；</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        var arr = ["a","b","c","d","e"];</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        arr.indexOf("a");        //0</span></span></span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">        //返回</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">当前查询字符所在的位置的下标，如果查询不到，返回-1，start表示从第几位开始查询。</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">        </span></span></span></span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">    2.forEach(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">callback</span></font><span style="font-size: 14px; background-color: rgb(251, 250, 248); font-family: &quot;Courier New&quot;;">); 循环，遍历数组</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">        var arr = [2,3,4,5,6,7,8];</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">        arr.forEach(function(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">value</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">index</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;;">arr</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">            console.log(value,index,arr);</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">            //函数中的三个参数分别代表，该项的值，该项下标，数组本身</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">        })</span></font></div><div><br/></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    3.map(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">callback</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">); 会遍历当前数组，然后调用参数中的方法，返回当前方法的返回值；</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        3.1 执行次数和参数，参考forEach</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            var arr = [2,3,4,5,6];</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            arr.map(function(value,index,arr){</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">                console.log(value,index,arr);</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            })</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        3.2 返回值 及 应用</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            map不会改变原有数组，而是将函数执行一次之后的返回值组成一个新数组，返回出来</span></span></span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">            </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">var arr = [2,3,4,5,6];</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    var newArr = arr.map(function(value,index,arr){</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">      </span> <span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">         return value-1;</span></span></span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">})</span></font></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            console.log( newArr );  //得到一个经过计算的数组</span></span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            </span></span></span></span></span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    4.filter(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">callback</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">); 同map方法，返回值为布尔值true 的时候，才会返回该</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">数据</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">        </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">4.1 同map的3.1</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">        4.2 filter不会改变原有数组，而是将函数执行一遍，只有在布尔值为true的时候才会返回</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(255, 38, 0);">该数据</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 0);">var arr = [2,3,4,5,6];</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    var newArr = arr.filter(function(value,index,arr){</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);"> </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">   </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    return value &gt; 3;</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">})</span></font></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    console.log( newArr );  //得到一个经过筛选的数组</span></font></div><div><br/></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">3.字符串的两种创建方式（常量和构造函数）</span></span></span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    字符串的创建：</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    var str = "hello world";                 //常量，基本类型创建</span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    var str2 = new String("hello world");    //构造函数创建</span></span></span></span></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    字符串的属性：</span></span></span></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    str.length        //字符串的长度</span></span></span></span></div><div style="font-size: 12px;"/></div><div><br/></div><div><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">4.字符串常见API（</span><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">indexOf／</span><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">charAt／substring／slice／split／replace）</span></div><div style="box-sizing: border-box; padding: 8px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248);"><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">1.indexOf(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">data</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(4, 51, 255); font-family: &quot;Courier New&quot;;">start</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">);   //<span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">用于返回某个数组或者字符串中规定字符或者字符串的位置；</span></span></font></span></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">        var str = "abcdefg”;</span></font></span></span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">        str.indexOf("a");</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    //0 <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">返回</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(0, 0, 0); font-family: &quot;Courier New&quot;;">当前查询字符所在的位置的下标，如无，返回-1，start表示从第几位开始查询。</span></span></font></div><div><br/></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    2.charAt(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">index</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">);         //返回指定位置的字符,index为下标</span></font></div><div><br/></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    3.substr(</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">n</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">,</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(4, 51, 255); font-family: &quot;Courier New&quot;;">m</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">);           </span></div><div><br/></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    4.substring(</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">n</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">,</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(4, 51, 255); font-family: &quot;Courier New&quot;;">m</span><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">);        //返回从指定位置n，到结束位置（不含）m 的字符串，如果不指定结束位置，则从开始位置到结尾</span></span></div><div><br/></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    5.slice(</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(255, 38, 0); font-family: &quot;Courier New&quot;;">n</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(4, 51, 255); font-family: &quot;Courier New&quot;;">m</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">);            //同substring，需要注意和数组中方法slice()的相似</span></font></div><div><br/></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    6.split("-");</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">            //通过指定字符分割字符串，返回一个数组</span></font></div><div><br/></div><div><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248);"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    7.replace("需要替换的字符串","替换之后的字符串")    //将字符串中的一些字符替换为另外一些字符。最好配合正则使用</span></span></span></span></span></div><div><br/></div><div><a href="http://www.w3school.com.cn/jsref/jsref_obj_string.asp" style="font-family: &quot;Courier New&quot;;">http://www.w3school.com.cn/jsref/jsref_obj_string.asp</a></div></div><div><br/></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">第二节：应用</span></span></span></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">1.通过json数组实现商品列表（字符串和html）</span></span></span></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">2.敏感词过滤【喵了个喵=====&gt;***】</span></span></span></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">3.用户名格式要求</span></span></span></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">        1.不允许为空，有提示</span></span></span></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">        2.不允许以数字开头</span></span></span></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">        3.长度必须在6~20之间</span></span></span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">第三节：精讲</span></span></span></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">1.字符串的重要性案例</span></span></span></div><div style="box-sizing: border-box; padding: 8px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    观察京东商品数据</span></span></span></div><div style="text-align: center;"><div><span style="background-color: rgb(251, 250, 248); font-size: 12px;"><span style="font-size: 12px; background-color: rgb(251, 250, 248); font-family: &quot;Courier New&quot;;"><img src="DAY07%EF%BC%9AES5_String.resources/A61E7E0F-F400-4ECE-B585-8C899F7CE5E9.png" height="341" width="1186"/><br/></span></span></div></div><div><br/></div><div><br/></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    js的重要作用之一－－－－交互－－－－人机交互（事件）－－－－服务器交互（ajax）</span></span></span></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span></span></span></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    服务器交互，从服务器获取数据，数据的处理方式，将json对象－－－－转换成字符串操作。</span></span></span></div><div><br/></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    案例：商品列表</span></span></span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    字符串操作重要性不言而喻！</span></span></span></div><div><br/></div><div><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    字符串的操作：从1+1=2到1+1=11，有什么样的区别</span></span></span></div><div><br/></div></div><div><br/></div><div><span style="font-size: 18px;"><span style="font-size: 18px;"><span style="font-size: 18px; font-family: &quot;Courier New&quot;;">2.ASCII码和字符集</span></span></span></div><div style="box-sizing: border-box; padding: 8px; font-size: 12px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.14902);"><div><span style="background-color: rgb(251, 250, 248); font-size: 12px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    </span><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">ASCII</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">American Standard Code for Information Interchange</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">，美国信息交换标准代码。</span></font></div><div style="text-align: center;"><div><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="font-size: 14px; background-color: rgb(251, 250, 248); font-family: &quot;Courier New&quot;;"><img src="DAY07%EF%BC%9AES5_String.resources/E88CFB45-F0AF-499A-B638-AD13804CE7B8.gif" height="362" width="288"/><br/></span></span></div></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">Unicode</span></span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">编码：</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    Unicode</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">（统一码、万国码、单一码）是计算机科学领域里的一项业界标准</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">包括字符集、编码方案等。</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">Unicode</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">是为了解决传统的字符编码方案的局限而产生的，它为每种语言中的每个字符设定了统一并且唯一的二进制编码，以满足跨语言、跨平台进行文本转换、处理的要求。</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">Unicode</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">目前普遍采用的是</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">UCS-2,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">它用两个字节来编码一个字符。</span></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">如汉字</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">"</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">经</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">"</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">的编码是</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">0x7ECF,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">注意字符码一般用十六进制来 表示，为了与十进制区分，十六进制以</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">0x</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">开头，</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">0x7ECF</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">转换成十进制 就是</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">32463,UCS-2</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">用两个字节来编码字符，两个字节就是</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">16</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">位二进制，</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">2</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">的</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">16</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">次方等于</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">65536,</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">所以</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">UCS-2</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">最多能编码</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">65536</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">个字符。</span></div><div><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">    </span></font></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">GBK</span></span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">编码：</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    GBK</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">全称《汉字内码扩展规范》（</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">GBK</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">即“国标”、“扩展”汉语拼音的第一个字母，英文名称：</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">Chinese Internal Code Specification</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">）。</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">GBK</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">向下与</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">GB2312</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">编码兼容，向上支持</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">ISO 10646.1</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">国际标准，是前者向后者过渡过程中的一个承上启下的产物。</span></div><div><font style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    <span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">UTF-8</span></span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">编码：</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">    UTF-8</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">（</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">8-bit Unicode Transformation Format</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">）是一种针对</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">Unicode</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">的可变长度字符编码，又称万国码。</span><span style="font-size: 12px;" /><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">UTF-8</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">用</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">1</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">到</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">4</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">个字节编码</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">UNICODE</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">字符。用在网页上可以同一页面显示中文简体繁体及其它语言（如英文，日文，韩文）。</span></div><h2><br/></h2><h2><font face="Courier New" style="font-size: 14px;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">字符串常见</span><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">API(charCodeAt\fromCharCode)</span></font></h2><div><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">1.myStr.charCodeAt(num)</span></span></span></div><div style="text-indent: 21pt;"><font face="Courier New" style="font-size: 14px;"><span style="text-indent: 21pt; background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">返回指定位置的字符的</span><span style="text-indent: 21pt; background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">Unicode</span><span style="text-indent: 21pt; background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">（是字符编码的一种模式）编码。</span></font></div><div><span style="background-color: rgb(251, 250, 248); font-size: 14px;"><span style="font-size: 14px; background-color: rgb(251, 250, 248);"><span style="font-size: 14px; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;; font-weight: bold;">2.String.fromCharCode()</span></span></span></div><div><span style="text-indent: 21pt; background-color: rgb(251, 250, 248); font-size: 12px; font-family: &quot;Courier New&quot;;"><span style="background-color: rgb(251, 250, 248); font-size: 14px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">  </span> <span style="background-color: rgb(251, 250, 248); font-size: 12px; font-family: &quot;Courier New&quot;; color: rgb(51, 51, 51);">String</span></span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">的意思就是不能用自己定义的字符串名字来调用，</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">只能用</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">String</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">来定义调用。接受一个或多个指定的</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">Unicode</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">值，然后返回一个或多个字符串。</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">(</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">把</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">unicode</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">编码转换为字符串</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">)</span><span style="font-size: 14px; text-indent: 21pt; background-color: rgb(251, 250, 248); color: rgb(51, 51, 51); font-family: &quot;Courier New&quot;;">。</span></div><div><br/></div></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">1.数字字母混合的验证码</span></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;"><img src="DAY07%EF%BC%9AES5_String.resources/ABE57093-4BD2-4580-9C3C-94949A767134.png" height="80" width="505"/><br/></span></div><div><br/></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">2-1.aabccd统计每个字符出现的次数，结果显示{a:2, b:1, c:2, d:1}</span></div><div><br/></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">2-2.去掉重复的字符，使结果显示abcd</span></div><div><br/></div><div><br/></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">3.随机生成一个五位以内的数，然后输出该数共有多少位，每位分别是什么</span></div><div><br/></div><div><br/></div><div><br/></div><div><span style="font-size: 14px; font-family: &quot;Courier New&quot;;">昨天作业中的数组去重的11中方法</span></div><div><span style="font-family: &quot;Courier New&quot;;"><a href="https://blog.csdn.net/weixin_41636483/article/details/112993238?spm=1001.2014.3001.5501">https://blog.csdn.net/weixin_41636483/article/details/112993238?spm=1001.2014.3001.5501</a></span></div><div><br/></div><div><br/></div></body></html>